//
//  AXFDaiboView.m
//  aixinfeng005
//
//  Created by 代波 on 16/10/11.
//  Copyright © 2016年 BBSWaitting. All rights reserved.
//

#import "AXFDaiboView.h"
#import "AXFDaiboFlowLayout.h"
#import "AXFDaiboCollectionViewCell.h"

static NSString *daiboCollectionID = @"daiboCollectionID";

@interface AXFDaiboView ()<UICollectionViewDataSource,UICollectionViewDelegate>

@end

@implementation AXFDaiboView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    AXFDaiboFlowLayout *flowLayout = [[AXFDaiboFlowLayout alloc] init];
    
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 120) collectionViewLayout:flowLayout];
    
    [self addSubview:collectionView];
    
    collectionView.backgroundColor = [UIColor whiteColor];
    
    collectionView.dataSource = self;
    collectionView.delegate = self;
    
    collectionView.showsHorizontalScrollIndicator = NO;
    collectionView.showsVerticalScrollIndicator = NO;
    
    [collectionView registerClass:[AXFDaiboCollectionViewCell class] forCellWithReuseIdentifier:daiboCollectionID];

}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _daiboHomeData.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    AXFDaiboCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:daiboCollectionID forIndexPath:indexPath];
    
    cell.daiboModel = _daiboHomeData[indexPath.item];

    return cell;
}

@end
